import { axios } from '@/utils/request'
import { Storetoken } from '../utils/wxstore'

// 获取评论
const getComents = async (params) => {
  let token
  try {
    token = await Storetoken.get()
  } catch (error) {
    console.log(error)
  }
  let headers = {}
  if (token !== '') {
    headers = {
      headers: {
        Authorization: 'Bearer ' + token
      }
    }
  }
  return axios.get('/public/comments', params, headers)
}

// 添加评论
const addComment = (editinfo) => axios.post('/comments/addcomments', editinfo)

// 更新
const updataComment = (data) => axios.post('/comments/updata', data)

// 采纳
const addBest = (params) =>
  axios.get('/comments/setbest', params)

// 点赞
const setHands = (handinfo) => {
  return axios.get('/comments/hands', handinfo)
}

export { getComents, addComment, updataComment, addBest, setHands }
